#!/usr/bin/env python
# -*- coding:utf8 -*-
# uncompyle6 version 2.15.1
# Python bytecode 2.7 (62211)
# Decompiled from: Python 2.7.10 (default, Jul  1 2017, 13:36:56) 
# [GCC 4.4.6 20110731 (Red Hat 4.4.6-4)]
# Embedded file name: /data/bkce/open_paas/paas/templates_module/engine/servers.html.py
# Compiled at: 2018-01-02 11:23:25
from mako import runtime, filters, cache
UNDEFINED = runtime.UNDEFINED
STOP_RENDERING = runtime.STOP_RENDERING
__M_dict_builtin = dict
__M_locals_builtin = locals
_magic_number = 10
_modified_time = 1514863405.594635
_enable_loop = True
_template_filename = '/data/bkce/open_paas/paas/templates/engine/servers.html'
_template_uri = 'engine/servers.html'
_source_encoding = 'utf-8'
_exports = [u'right_content']

def _mako_get_namespace(context, name):
    try:
        return context.namespaces[(__name__, name)]
    except KeyError:
        _mako_generate_namespaces(context)
        return context.namespaces[(__name__, name)]


def _mako_generate_namespaces(context):
    pass


def _mako_inherit(template, context):
    _mako_generate_namespaces(context)
    return runtime._inherit_from(context, u'/base_center.html', _template_uri)


def render_body(context, **pageargs):
    __M_caller = context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(pageargs=pageargs)
        paas_domain_host = context.get('paas_domain_host', UNDEFINED)

        def right_content():
            return render_right_content(context._locals(__M_locals))

        STATIC_URL = context.get('STATIC_URL', UNDEFINED)
        servers = context.get('servers', UNDEFINED)
        JS_SUFFIX = context.get('JS_SUFFIX', UNDEFINED)
        paas_domain_port = context.get('paas_domain_port', UNDEFINED)
        paas_domain = context.get('paas_domain', UNDEFINED)
        __M_writer = context.writer()
        __M_writer(u'
')
        if 'parent' not in context._data or not hasattr(context._data['parent'], 'right_content'):
            context['self'].right_content(**pageargs)
        __M_writer(u'
<script src="')
        __M_writer(unicode(STATIC_URL))
        __M_writer(u'js/paas_engine.')
        __M_writer(unicode(JS_SUFFIX))
        __M_writer(u'"></script>
')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_right_content(context, **pageargs):
    __M_caller = context.caller_stack._push_frame()
    try:
        paas_domain_host = context.get('paas_domain_host', UNDEFINED)
        paas_domain = context.get('paas_domain', UNDEFINED)

        def right_content():
            return render_right_content(context)

        paas_domain_port = context.get('paas_domain_port', UNDEFINED)
        servers = context.get('servers', UNDEFINED)
        __M_writer = context.writer()
        __M_writer(u'
<!-- 右侧内容 start -->
<div class="box-info full">
  <div class="main-header">
    <span>服务器信息</span>
  </div>
  <div class="dev_center_module">
    <h4 class="dev_module_title">
            &nbsp
           <button type="button" class="btn-info btn-xs env_add_btn f_r"><span aria-hidden="true" class="glyphicon glyphicon-plus"></span>添加服务器信息</button>
    </h4>
     <table class="table table-bordered dev_env_table mt10" id="user_env_table">
        <thead>
            <tr>
                <th width="16%">服务器ID</th>
                <th width="16%">Token</th>
                <th width="14%">IP</th>
                <th width="10%">Agent端口</th>
                <th width="11%">App服务端口</th>
                <th width="14%">类别</th>
                <th width="6%">启用</th>
                <th width="13%">操作</th>
            </tr>
        </thead>
        <tbody>
')
        if servers:
            for server in servers:
                __M_writer(u'                <tr class="env_record">
                    <input  type="hidden" class="server_id" disabled value="')
                __M_writer(unicode(server.id))
                __M_writer(u'" />
                    <td>
                        <span class="s_id">')
                __M_writer(unicode(server.s_id))
                __M_writer(u'</span>
                    </td>
                    <td>
                        <span class="server_token">')
                __M_writer(unicode(server.token))
                __M_writer(u'</span>
                    </td>
                    <td>
                        <input class="form-control server_ip" disabled value="')
                __M_writer(unicode(server.ip_address))
                __M_writer(u'" placeholder="请输入服务器IP"/>
                    </td>
                    <td>
                        <input  type="number" min="1" max="65535" class="form-control server_port" disabled value="')
                __M_writer(unicode(server.ip_port))
                __M_writer(u'" placeholder="请输入Agent端口"/>
                    </td>
                    <td>
                        <input  type="number" min="1" max="65535" class="form-control app_port" disabled value="')
                __M_writer(unicode(server.app_port))
                __M_writer(u'" placeholder="请输入App服务端口"/>
                    </td>
                    <td>
                        <select class="form-control server_cate" disabled placeholder="请选择服务器类别">
                            <option value="tapp" ')
                __M_writer(unicode('selected' if server.category == 'tapp' else ''))
                __M_writer(u' >测试服务器</option>
                            <option value="app" ')
                __M_writer(unicode('selected' if server.category == 'app' else ''))
                __M_writer(u'  >正式服务器</option>
                        </select>
                    </td>
                    <td>
                        <span class="server_active" data="')
                __M_writer(unicode('1' if server.is_active else '0'))
                __M_writer(u'">')
                __M_writer(unicode(u'是' if server.is_active else u'否'))
                __M_writer(u'</span>
                    </td>
                    <td>
                        <button type="button" class="btn-info btn-xs env_save_btn">保存</button>
                        <button type="button" class="btn-xs env_cancel_btn">取消</button>
                        <!-- 未激活服务器才能编辑，修改ip、端口等信息 -->
')
                if not server.is_active:
                    __M_writer(u'                            <a href="###" title="编辑" class="dev_env_opera env_edit_btn"><span aria-hidden="true" class="glyphicon glyphicon-edit"></span></a>
')
                __M_writer(u'                        <a href="###" value="')
                __M_writer(unicode(server.id))
                __M_writer(u'" title="删除" class="dev_env_opera env_del_btn"><span aria-hidden="true" class="glyphicon glyphicon-remove-circle"></span></a>
')
                if not server.is_active:
                    __M_writer(u'                            <a href="###" title="激活" class="dev_env_opera env_active_btn"><span aria-hidden="true" class="glyphicon glyphicon-saved"></span></a>
')
                else:
                    __M_writer(u'                            <a href="###" title="刷新" class="dev_env_opera env_refresh_btn"><span aria-hidden="true" class="glyphicon  glyphicon-refresh"></span></a>
')
                __M_writer(u'                    </td>
                </tr>
')

        else:
            __M_writer(u'            <tr id="no_record_row"><td colspan="8"><center>没有服务器信息</center></td></tr>
')
        __M_writer(u'        </tbody>
    </table>
    <h4 class="dev_module_title mt30">使用说明</h4>
    <div class="env_introduce_box">
        <p>AppServer是在蓝鲸智云上注册的应用部署的服务器 </p>
        <p>Agent端口：PaaSAgent 的启动端口 </p>
        <p>App服务端口：App服务器上，App代理服务Nginx端口 </p>
        <p>请确认AppServer上能访问到蓝鲸智云开发者中心，即在服务器上 <code>ping ')
        __M_writer(unicode(paas_domain_host))
        __M_writer(u'</code> 能通，并且 <code>telnet ')
        __M_writer(unicode(paas_domain_host))
        __M_writer(u' ')
        __M_writer(unicode(paas_domain_port))
        __M_writer(u' </code>有效</p>
        <hr>
        <p>服务器信息添加后，还需要在服务器上部署 PaaSAgent，PaaSAgent部署步骤如下（PaaSAgent软件包在蓝鲸智云PaaS项目的“paas_agent”目录中）：<br>
          <span class="ml20">1.初始化环境安装（详细步骤请按照软件包中 <code>Install.md</code> 实施）</span><br>
          <span class="ml20">2.<code>cp /data/paas/paasagent/etc/paas_agent_config.yaml_sample /data/paas/paasagent/etc/paas_agent_config.yaml</code> </span> <br>
           <span class="ml20">3.编辑paas_agent_config.yaml文件，将配置值按需写入:</span> <br>
           <span class="ml40">a. 将<code>服务器ID</code>写入paas_agent_config.yaml文件中的<code>s_id</code></span> <br>
           <span class="ml40">b. 将<code>Token</code>写入paas_agent_config.yaml文件中的<code>token</code></span> <br>
           <span class="ml40">c. 将App Engine地址<code>http://')
        __M_writer(unicode(paas_domain))
        __M_writer(u'</code>写入paas_agent_config.yaml文件中的<code>CONTROLLER_SERVER_URL</code></span> <br>
           <span class="ml20">4. 从官网下载证书文件，并解压到 <code>/data/paas/paasagent/etc</code> 目录下，其中包含 <code>platform.cert</code> 和 <code>paltform.key</code> 两个文件</span> <br>
           <span class="ml20">5. 执行<code>./bin/install.sh</code>命令，启动PaasAgent</span> <br>
           <span class="ml20">6. 点击页面上的激活按钮(<span aria-hidden="true" class="glyphicon glyphicon-saved"></span>)激活服务器 </span> <br>
           <span class="ml20">7. 修改 nginx.conf 配置， 将连接指向 PaaSAgent 服务器(分测试环境和正式环境， 具体变更方式见安装文档) </span> <br>
        </p>
        <hr>
        <p>如果要停用已激活的服务器，点击页面上的删除按钮(<span aria-hidden="true" class="glyphicon glyphicon-remove-circle" style="color: #44b549;"></span>)删除服务器即可；删除后， 将无法在该机器上部署应用</p>
        <p>如果启用新的机器， 则之后的部署操作， 都会在新的机器上进行；此时若 nginx 没有变更，用户访问服务还是老机器上的，需变更 nginx，将测试/正式环境指向新的机器，并重新加载配置</p>
        <p>如果进行机器迁移， 即要停用某个机器， 将服务迁移到新的机器，请按以下步骤执行：<br>
            <span class="ml20">1. 停用老机器</span> <br>
            <span class="ml20">2. 注册并激活新机器</span> <br>
            <span class="ml20">3. 对所有已上线应用， 执行重新上线</span> <br>
            <span class="ml20">4. 修改nginx.conf中测试/正式环境机器配置， 重新加载配置</span> <br>
            <span class="ml20">5. 完成迁移</span> <br>
        </p>
        <p>测试环境/正式环境分别只能激活一台服务器</p>
        <p>如果用到数据库， 需要对激活的服务器授权</p>
        <p>只有管理员可以管理服务器信息 </p>
    </div>
  </div>
</div>
')
        return ''
    finally:
        context.caller_stack._pop_frame()
